{include file="public/head"/}
<style>
    body {
        background-color: #ffffff;
    }
</style>

<body>
    <div class="layui-form layuimini-form">
        <input type="hidden" name="id" value="{$info.id}">
        <div class="layui-form-item">
            <label class="layui-form-label required">所属用户组</label>
            <div class="layui-input-block">
                <select name="group_id" lay-verify="required" lay-search lay-verify="required" lay-reqtext="必须选择用户组">
                    <option value="">请选择用户组</option>
                    {volist name="authGroup" id="vo"}
                    <option value="{$vo.group_id}" {$info.group_id==$vo.group_id?'selected':''}>{$vo.title}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username" value="{$info.username}" lay-verify="required" lay-reqtext="请输入登录用户名" placeholder="请输入用户名"
                    value="" class="layui-input">
                <tip>填写自己管理账号的名称。</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" class="layui-input" autocomplete="off">
                <tip>密码长度6-15位.</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-inline">
                <input type="text" name="realname" value="{$info.realname}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机</label>
            <div class="layui-input-block">
                <input type="number" name="phone" placeholder="请输入手机"
                    value="{$info.phone}" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                <a href="javascript:;"  class="layui-btn layui-btn-primary layui-border" lay-active="closePage">关闭</a>
            </div>
        </div>
    </div>
    </div>
    <script>
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer,
                util = layui.util,
                $ = layui.$;

            //监听提交
            form.on('submit(saveBtn)', function (data) {
                // 提交到方法 默认为本身
                $.post("{:url('edit')}",data.field,function(res){
                    if(res.code > 0){     
                      layer.msg(res.msg,{time:1800,icon:1});
                      // 关闭弹出层
                      setTimeout(() => {
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
                        parent.layer.close(iframeIndex);
                      }, 1800);
                    
                    }else{
                        layer.msg(res.msg,{time:1800,icon:2});
                    }
                });
            });

            util.event('lay-active',{
                closePage: function() {
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                }
            });

        });
    </script>
    {include file="public/footer"/}